

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author HPG60
 */
public class Collisions extends JFrame{

    JPanel pnlPanneau_1;
    JPanel pnlPanneau_2;
    JPanel pnlPanneau_3;

    JButton btnGo;

    JRadioButton deuxDim;
    JRadioButton uneDim;
    ButtonGroup groupeBouton;

    boolean estUneDim;

    GererEvenement eventMan;

    private static Collisions instance;

    private Collisions(){
        super();

        estUneDim = true;

        eventMan = new GererEvenement();
        this.setLocation(400, 300);
        this.setTitle("Choix de dimension");
        this.setSize(400,150);

        pnlPanneau_3=new JPanel(new GridLayout(2,0));

        pnlPanneau_1 = new JPanel();

        btnGo = new JButton("Go");
        pnlPanneau_2=new JPanel();

        pnlPanneau_1.add(btnGo);

        uneDim=new JRadioButton("Collision a une dimension");
        uneDim.setSelected(true);
        deuxDim=new JRadioButton("Collision a deux dimension");
        groupeBouton=new ButtonGroup();
        groupeBouton.add(uneDim);
        groupeBouton.add(deuxDim);

        pnlPanneau_2.add(uneDim);
        pnlPanneau_2.add(deuxDim);

        pnlPanneau_3.add(pnlPanneau_2);
        pnlPanneau_3.add(pnlPanneau_1);

        this.add(pnlPanneau_3);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);

        btnGo.addActionListener(eventMan);
    }

    public boolean getEstUneDim() {
        return estUneDim;
    }

    public static Collisions getInstance(){
        if(instance==null){
            instance=new Collisions();
        }
        return instance;
    }

    class GererEvenement implements ActionListener {

        public void actionPerformed(ActionEvent ae) {

            if(ae.getSource()==btnGo){
                Fenetre.getInstance().setVisible(true);
                dispose();
            }

            estUneDim = uneDim.isSelected();
        }
    }

}
